package com.mde.xmlreader;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class CoordsParser {
	
	private static String fileIn = "stations.txt";
	
	private static String fileOut = "stationsHtml.html";

	public static void main(String[] args) throws FileNotFoundException {
		
		Scanner scan = new Scanner(new File(fileIn));
		PrintWriter file = new PrintWriter(new File(fileOut));
		
		String htmlStart = "<!doctype html>\n" +
				"<html>\n" +
				"<title>Points on the map</title>\n" +
				"<head>\n" +
				"<meta charset=\"utf-8\" />" +
				"<script src=\"http://api-maps.yandex.ru/2.0/?load=package.standard&lang=ru-RU\" type=\"text/javascript\"></script>" +
				"<script type=\"text/javascript\" src=\"js.js\"></script>" +
				"</head>\n" +
				"<body>\n" +
				"<div id=\"map\" style=\"width:900px; height:700px\"></div>";
		
		file.write(htmlStart);
		int count = 0;
		
		while (scan.hasNext()) {
			double lat = scan.nextDouble(), lon = scan.nextDouble();
			++count;
			file.write("\t<span id=\"" + count + "lat\">" + lat + "</span> ");
			file.write("\t<span id=\"" + count + "lon\">" + lon + "</span><br />\n");			
		}
		
		String htmlEnd = "</body>\n" +
				"</html>\n";
		
		file.write(htmlEnd);				
		
		file.close();
		scan.close();
		
	}
	
}
